<script setup>
const props = defineProps({
    item: {
        type: Object,
    }
})
const emit = defineEmits(["preview", "designer", "edit", "delete"])
</script>

<template>
    <div class="TemplateCell">
        <div class="image">
            <img :src="item.image" />
        </div>
        <div class="info">

            <div class="name">
                <el-text line-clamp="2">
                    {{ item.name }}
                </el-text>
            </div>
            <div class="actions">
                <el-button @click="emit('preview', item)" link size="small" type="primary">
                    <b-icon name="bi-eye" size="14" style="margin-right: 4px" />
                    预览
                </el-button>
                <el-button @click="emit('designer', item)" link size="small" type="success">
                    <b-icon name="bi-brush" size="12" style="margin-right: 4px" />
                    设计
                </el-button>
                <el-button @click="emit('edit', item)" link size="small" type="primary">
                    <b-icon name="bi-pencil-square" size="13" style="margin-right: 4px" />
                    修改
                </el-button>
                <el-button @click="emit('delete', item)" link size="small" type="danger">
                    <b-icon name="bi-x-lg" size="14" style="margin-right: 1px" />
                    删除
                </el-button>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.TemplateCell {
    margin-right: 20px;
    margin-bottom: 20px;
    width: 240px;
    height: 330px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);

    .image {
        box-sizing: border-box;
        width: 100%;
        height: 240px;
        background: #fff;
        overflow: hidden;
        padding: 10px;

        img {
            box-sizing: border-box;
            width: 100%;
            height: auto;
            transition: transform 0.3s ease;
            transform: scale(1.1) translateY(10px);
        }

        &:hover {
            img {
                transform: scale(1.4) translateY(50px);
            }
        }
    }

    .info {
        border-top: 1px solid #ccc;

        .name {
            box-sizing: border-box;
            width: 100%;
            height: 60px;
            font-size: 16px;
            font-weight: bold;
            padding: 10px;
        }

        .actions {
            display: flex;
            flex-direction: row;
            justify-content: space-around;
            align-items: center;
            box-sizing: border-box;
            width: 100%;
            padding: 0 10px;
        }
    }
}
</style>